#pragma once

#include "Netdefs.h"

#include <cv.h>
#include <highgui.h>

#include <list>
using std::list;
#include <vector>
using std::vector;

typedef std::list<IplImage*> t_imageList;

#define NUMBERS_IN_PLATE 7

class FrontCamHander{
public:
	FrontCamHander( CvCapture *camCapture , SocketClient *socketToDB ) : m_camCapture(camCapture), m_socketToDB(socketToDB) {}
	void operate();
private:
	bool			waitForCar();
	bool			waitForCarExit();
	bool			checkForCarMovement( IplImage* previousImageCapture , IplImage* currentImageCapture );
	bool			getStartingPoint( IplImage *image, CvPoint& startingPoint , int colorThresholdLow = 0, int colorThresholdHigh = 255, bool reset = false ); 
	/* getStartingPoint
	 * goes over image and always get a new starting point in threshold limits
	 * gets grayscale image 
	 * should be reset between images 
	 */
	bool			isThereBigObject( IplImage *image, int widthThreshold = 0, int heightThreshold = 0 , int colorThresholdLow = 0, int colorThresholdHigh = 255  ); 
	/* isThereBigObject
	 * invalidates velocity images
	 * gets grayscale image 
	 */
	IplImage*		medianFilter( IplImage *source , int windowSize );

	/* next 3 functions help getting a plate number from several images */
	void			addPlateNum( unsigned long currentPlateNum );
	void			emptyPlateNum();
	unsigned long	getPlateNum();

	inline  double	getVelocity( IplImage* velImageX, IplImage* velImageY, int xPixel, int yPixel );

	CvCapture		*m_camCapture;
	SocketClient	*m_socketToDB;
	t_imageList		m_imgList;
	vector<int>		m_digits[NUMBERS_IN_PLATE];
};
